import com.cn.Mapper.vipMapper.VipcustomerMapper;
import com.cn.entity.vip.Vipcustomer;
import com.cn.entity.vip.Vipcustomer_Search;
import com.cn.util.SqlsesstionUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

import java.util.List;

/**
 * @ClassName testVip
 * @Description TODO
 * @Author yujiajing
 * @Date 2022/10/10 8:46
 * @Version 1.0
 */
public class testVip {
    /**
     * 类型：单元测试
     * 目的：测试VIP客户的删除是否可用
     */
    @Test
    public void delete_vip(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
       VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
       vipcustomerMapper.deleteVipcoustomer("1");
    }

    /**
     * 单元测试
     * 测试显示VIP的操作是否可用
     */
    @Test
    public void selectVipcustomer(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
         List<Vipcustomer> vipList=vipcustomerMapper.selectVipcustomer();
         System.out.println(vipList.toString());
    }
    @Test
    public void insertVIpcustomer(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        Vipcustomer vipcustomer=new Vipcustomer("5","李华","66","44","22","22","99");
        vipcustomerMapper.insertVipcustomer(vipcustomer);
    }
    @Test
    public  void  insertVipByIdCard(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
       vipcustomerMapper.insertVipByIdCard("222");
    }
    @Test
    public  void  showSearch(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
       List<Vipcustomer_Search> vipcustomer_searchList= vipcustomerMapper.showSearch();
        System.out.println(vipcustomer_searchList.toString());
    }
    @Test
    public  void emptyVip_search(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        vipcustomerMapper.emptyVip_Search();
    }
  @Test
    public void SearchvipByCartId(){
      String vip_CardId="111";
      SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
      VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
      //清空搜索表
      vipcustomerMapper.emptyVip_Search();
      //插入搜索信息
      vipcustomerMapper.insertVipByIdCard(vip_CardId);
        //显示搜索信息
    /*  List<Vipcustomer_Search> vipcustomer_searchList= vipcustomerMapper.showSearch();
      System.out.println(vipcustomer_searchList.toString());*/
    }

    @Test
    public void loginVip(){
        SqlSession sqlSession = SqlsesstionUtil.getSqlSession();
        VipcustomerMapper vipcustomerMapper = sqlSession.getMapper(VipcustomerMapper.class);
        Vipcustomer vipcustomer =vipcustomerMapper.loginByCartId("111");
        System.out.println(vipcustomer.toString());

    }
}
